Option Strict Off
Option Explicit On
Imports System.Windows.Media

Namespace Facades
    Public NotInheritable Class AnimationFacade

        Private brother As Infragistics.Windows.Chart.Animation

        Public Sub New(ByVal brother As Infragistics.Windows.Chart.Animation)
            MyBase.New()
            Me.brother = brother
        End Sub

        Public Property Duration() As Double
            Get
                Return Me.brother.Duration.TimeSpan.TotalSeconds
            End Get
            Set(ByVal value As Double)
                Me.brother.Duration = New Windows.Duration(TimeSpan.FromSeconds(value))
            End Set
        End Property

        Public Property AccelerationRatio() As Double
            Get
                Return Me.brother.AccelerationRatio
            End Get
            Set(ByVal value As Double)
                Me.brother.AccelerationRatio = value
            End Set
        End Property

        Public Property DecelerationRatio() As Double
            Get
                Return Me.brother.DecelerationRatio
            End Get
            Set(ByVal value As Double)
                Me.brother.DecelerationRatio = value
            End Set
        End Property

        Public Property Sequential() As Boolean
            Get
                Return Me.brother.Sequential
            End Get
            Set(ByVal value As Boolean)
                Me.brother.Sequential = value
            End Set
        End Property


        Public Function InternalToXElement() As XElement
            Dim x = <Animation
                        Duration=<%= Duration %>
                        DecelerationRatio=<%= DecelerationRatio %>
                        AccelerationRatio=<%= AccelerationRatio %>
                        Sequential=<%= Sequential %>
                    />

            Return x
        End Function


        Public Sub InternalFromXElement(ByVal x As System.Xml.Linq.XElement)
            Dim cd = Function(s As String) Double.Parse(s, Globalization.CultureInfo.InvariantCulture)

            Me.Duration = cd(x.@Duration)
            Me.Sequential = x.@Sequential
            Me.DecelerationRatio = cd(x.@DecelerationRatio)
            Me.AccelerationRatio = cd(x.@AccelerationRatio)
        End Sub

        'Public Function Clone(ByVal brother As Infragistics.Windows.Chart.Animation) As AnimationFacade
        '    Dim result = New AnimationFacade(brother)
        '    result.Duration = Me.Duration
        '    result.Sequential = Me.Sequential
        '    result.DecelerationRatio = Me.DecelerationRatio
        '    result.AccelerationRatio = Me.AccelerationRatio

        '    Return result
        'End Function
    End Class
End Namespace
